<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <include file="Public:head"/>
  <link rel="stylesheet" media="all" type="text/css" href="/Public/css/jquery-ui.css" />
  <link rel="stylesheet" media="all" type="text/css" href="/Public/css/jquery-ui-timepicker-addon.css" />
</head>
<body>
<style type="text/css">
    .m-li{
        float: left;
    }
    .active{
        border-bottom:2px solid #0a6ebd;
    }
</style>
  <div class="panel admin-panel">
    <ul>
        <li class="panel-head m-li <eq name='status' value='1'> active</eq>"> <a href="{:U('message',array('status'=>1))}"><strong class="icon-reorder">留言列表</strong></a></li>
        <li class="panel-head m-li <eq name='jubao' value='2'> active</eq>"> <a href="{:U('message',array('jubao'=>2))}"><strong class="icon-thumbs-down"> 被举报列表</strong></a></li>
        <li class="panel-head m-li <eq name='status' value='0'> active</eq>"><a href="{:U('message',array('status'=>0))}"><strong class="icon-remove"> 已删除列表</strong></a></li>
    </ul>
      <div style="clear:both;"></div>
    <form action="{:U('message')}">
     <div class="padding border-bottom">
      <ul class="search" style="padding-left:10px;">
        <li>搜索：</li>
        <li>
          <input type="text" placeholder="开始时间" name="b_time" class="input"  id="b_time" style="width:180px; line-height:17px;display:inline-block" value="{$b_time}">
          <input type="text" placeholder="截止时间" name="e_time" class="input" id="e_time" style="width:180px; line-height:17px;display:inline-block" value="{$e_time}">
          <input type="text" placeholder="请输入发帖人" name="keywords" class="input" style="width:250px; line-height:17px;display:inline-block" value="{$keywords}">
          <button type="submit"class="button border-main icon-search" > 搜索</button></li>
       <neq name="status" value="0">
        <li>
          <button type="button"  class="button border-green" id="checkall" ><span class="icon-check"></span> 全选</button>
          <button type="button" class="button border-red pl_del" ><span class="icon-trash-o"></span> 批量删除</button>
        </li>
       </neq>
      </ul>
    </div>
    </form>
    <table class="table table-hover text-center">
      <tr>
        <th width="5%">ID</th>
        <th width="20%">发帖人</th>
        <th width="30%">内容</th>
         <th width="10%">留言时间</th>
         <th width="10%">是否匿名</th>
         <th width="5%">状态</th>
        <th>操作</th>
      </tr>      
        <volist name="list" id="l">
          <tr>
            <td><input type="checkbox"  class="c_td" name="id[]" value="{$l.message_id}" />
              {$l.message_id}</td>
            <td>
                <span style="font-size: 15px;"><a href="{:U('user',array('keywords'=>$l['username']))}">{$l.username}</a></span>
                <span  class="icon-heart" style="padding-left: 20px;display: inline-block;font-size: 15px;"><i class="span_i" style="display: inline-block;font-size: 10px;padding-left: 3px;">{$l.like_num|default="0"}</i></span>
                <empty name="l.report_num">
                    <span  class="icon-bell" style="padding-left: 10px;display: inline-block;font-size: 15px;"><i class="span_i" style="display: inline-block;font-size: 10px;padding-left: 3px;">{$l.report_num|default="0"}</i></span>
                    <else/>
                    <a href="{:U('message_report',array('message_id'=>$l['message_id']))}"><span  class="icon-bell" style="padding-left: 10px;display: inline-block;font-size: 15px;"><i class="span_i" style="display: inline-block;font-size: 10px;padding-left: 3px;">{$l.report_num|default="0"}</i></span></a>
                </empty>
                <empty name="l.commet_num">
                    <span  class="icon-comment" style="padding-left: 10px;display: inline-block;font-size: 15px;"><i class="span_i" style="display: inline-block;font-size: 10px;padding-left: 3px;">{$l.commet_num|default="0"}</i></span>
                    <else/>
                    <a href="{:U('message_comment',array('message_id'=>$l['message_id']))}"><span  class="icon-comment" style="padding-left: 10px;display: inline-block;font-size: 15px;"><i class="span_i" style="display: inline-block;font-size: 10px;padding-left: 3px;">{$l.commet_num|default="0"}</i></span></a>

                </empty>
            </td>
            <td>{$l.con}</td>
            <td>{$l.add_time}</td>
            <td>{$l.type}</td>
            <td>{$l.s_type}</td>
            <td>
              <div class="button-group edit_btn" data-content="{$l.content}"> 
                <a class="button border-blue" href="javascript:void(0)">
                  <span class=" icon-list"></span> 详情
                </a> 
              </div>
              <eq name="l.status" value="0">
                <div class="button-group no_del" style="background-color: gray;" data-id="{$l.message_id}"> 
                  <a class="button" href="javascript:void(0)">
                    <span class="icon-trash-o"></span> <font style="color:red;">已删除</font>
                  </a> 
                </div>                  
              <else/>
                <div class="button-group del_btn" data-id="{$l.message_id}"> 
                  <a class="button border-red" href="javascript:void(0)">
                    <span class="icon-trash-o"></span> 删除
                  </a> 
                </div>                  
              </eq>

              
            </td>
          </tr>
        </volist>
      <tr>
        <td colspan="8" class="page">{$show}</td>
      </tr>
    </table>
  </div>
</body>
<script type="text/javascript" src="/Public/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="/Public/js/jquery-ui-timepicker-addon.min.js"></script>
<script type="text/javascript" src="/Public/js/jquery-ui-timepicker-zh-CN.js"></script>
</html>
<script type="text/javascript">

   $(function () {
       $("#checkall").click(function(){
           $("input[name='id[]']").each(function(){
               if (this.checked) {
                   this.checked = false;
               }
               else {
                   this.checked = true;
               }
           });
       })

       $('#b_time,#e_time').datetimepicker({

       });
       $('.del_btn').click(function(){
           var message_id =$(this).attr('data-id');
           swal({
               title: "您确认要删除么？",
               text: "",
               type: "info",
               showCancelButton: true,
               confirmButtonColor: "#AEDEF4",
               cancelButtonText: "取消",
               confirmButtonText: "确定",
               closeOnConfirm: false,
               closeOnCancel: true
           }, function(isConfirm){
               if (isConfirm) {
                   $.post('{:U("del_message")}',{"message_id":message_id},function(msg){
                       if(msg.status == 0){
                           sweetAlert({title:'',text: msg.info,type: "warning",timer:2000,showConfirmButton: false});
                       }
                       if(msg.status == 1){
                           sweetAlert({title:'',text: msg.info,type: "success",showConfirmButton: false});
                           setTimeout(function(){window.location.reload()},2000);
                       }
                   });
               }
           });

       });


       $('.pl_del').click(function(){
           swal({
               title:'您确定要批量删除？',
               type: "info",
               showCancelButton: true,
               confirmButtonColor: "#AEDEF4",
               cancelButtonText: "取消",
               confirmButtonText: "确定",
               closeOnConfirm: false,
               closeOnCancel: true
           },function(isConfirm){
               if (isConfirm){
                   var ids ='';
                   $('.c_td:checked').each(function(){
                           ids +=','+$(this).val();
                       }
                   );
                   $.post("{:U('pl_del')}",{
                       ids:ids
                   },function(msg){
                       if(msg.status == 0){
                           sweetAlert({title:'',text: msg.info,type: "warning",timer:2000});
                       }
                       if(msg.status == 1){
                           sweetAlert({title:'',text: msg.info,type: "success"});
                           setTimeout(function(){window.location.reload()},2000);
                       }
                   });
               }else{

               }
           });
       });
       $('.edit_btn').click(function(){
           var con = $(this).attr('data-content');
           swal({
               title: "留言内容",
               text: con,
               html: true
           }, function(){
       });
       });
   })
  //点击 灰色的删除
  $('.no_del').click(function(){
    sweetAlert({title:'',text: "当前帖子是已经处于删除状态！！！",type: "warning",timer:2000,showConfirmButton: false});
  });
</script>